package com.coderfans.logwrapper;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import java.util.Properties;

/**
 * Created by ${fanchunshuai} on 2016-11-15.
 *
 * @version: V1.0
 * @Desc:
 * @Copyright (c) 2016 58到家-版权所有
 */
public class LogConfig {
    private Logger logger = Logger.getLogger(this.getClass());
    private static void initLog(){
        Properties prop = new Properties();
        //设定输出到控制台
        //prop.setProperty("log4j.rootLogger", "DEBUG, CONSOLE, INFO, FILE");
        //prop.setProperty("log4j.appender.CONSOLE", "org.apache.log4j.ConsoleAppender");
        //prop.setProperty("log4j.appender.CONSOLE.layout", "org.apache.log4j.PatternLayout");
        //prop.setProperty("log4j.appender.CONSOLE.layout.ConversionPattern", "%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %-5p %C{1} : %m%n");
        //设定输出到文件

        prop.setProperty("log4j.appender.file", "org.apache.log4j.DailyRollingFileAppender");
        prop.setProperty("log4j.appender.file.File", "D:/data_collection/logs/log_");
        prop.setProperty("log4j.appender.file.DatePattern", "'_'yyyy-MM-dd'.log'");
        prop.setProperty("log4j.appender.file.layout", "org.apache.log4j.PatternLayout");

        PropertyConfigurator.configure(prop);
    }
}
